<?php App::import('Sanitize'); ?>
<div class="breadcrumbs">		
	<?php
	$items = array(
		array('Home', array('controller' => 'users', 'action' => 'updates')),
		array('Inbox', array('controller' => 'messages', 'action' => 'inbox')),
		array(Sanitize::html($conversation['0']['Message']['subject']), array('controller' => $this->params['controller'], 'action' => $this->params['action'], $this->params['pass'][0]))
	);
	echo $this->Navigation->breadcrumbs($items);
	?>
</div>

<div class="welcome">
	<h2>Bericht</h2> <h1><?php echo Sanitize::html($conversation['0']['Message']['subject']); ?></h1>
		<div class="message-options">
			<div class="delete">
				<?php
				$id = $conversation['0']['Message']['id'];
				echo $this->Html->link(' ', array('controller' => 'messages', 'action' => 'delete', $id));
				?>
				</div>
			<div class="reply">
				<?php
				$id = $this->Message->get_reply_id($conversation);
				echo $this->Html->link(' ', array('controller' => 'messages', 'action' => 'send', $id));
				?>
			</div>
		</div>
</div>

<?php foreach($conversation as $message): ?>
	<?php $userGroup = $message["User"]["group_id"]; ?>
	<div class="content-wrapper ui-corner-all">	
		<div class="block-white-top ui-corner-all">
			<div class="clear"></div>
				<div class="message-header">
					<div class="message-info">
					<a name= "<?php echo $message['Message']['id'] ?>"></a>
						<table>
						<tr><td>Van:</td><th><h1><?php 
						
						if ($userGroup == 1 ) { 
						echo $this->Html->link(Sanitize::html($message['User']['username']), array('controller' => 'designer_profiles', 'action' => 'view', $message['User']['DesignerProfile']['id'])); } else {
						echo $this->Html->link(Sanitize::html($message['User']['username']), array('controller' => 'contractor_profiles', 'action' => 'view', $message['User']['ContractorProfile']['id']));
						}
						
						?></h1></th></tr>
						<tr><td>Aan:</td><th><?php echo Sanitize::html($message['Message']['to_user']); ?></th></tr>
						<tr><td>Onderwerp:</td><th><?php echo Sanitize::html($message['Message']['subject']); ?></th></tr>
						<tr><td>Datum:</td><th><?php echo $this->FixDate->fix_date($message['Message']['created'], 'time'); ?></th></tr>
						</table>
					</div>
				</div>
				<hr/>
					<div class="message">
					<?php 
						$dingen = array('\n', '\\');
						$replace = array('<br />',  '');
					?>
					<p><?php echo str_replace($dingen, $replace, Sanitize::html($message['Message']['body'])); ?></p>
					</div>
				<div class="clear"></div>	
		</div>
	</div>
<?php endforeach; ?>
